package future;

import java.util.concurrent.Callable;

/**
 * @author fei
 * @date 2023/1/3 13:18
 * @description callable 和  接口的对比
 */
public class CallableAndRunnable {

    /**
     * 继承 Runnable，线程不会有返回值
     */
    public class Thread1 implements Runnable{
        @Override
        public void run() {
            System.out.println("线程开启！");
        }
    }

    /**
     * 继承 Callable 接口可以有返回值
     */
    public class Thread2 implements Callable<String>{
        @Override
        public String call() throws Exception {
            System.out.println("线程开启！");
            return "hello, world!";
        }
    }

}
